package com.ss.android.article.lite;

import android.app.UiModeManager;
import android.content.Context;

import com.bytedance.common.utility.Logger;
import com.bytedance.frameworks.b.a.ComponentsManifest;
import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.ss.android.article.base.app.BizApplication;
import com.ss.android.article.base.app.j;
import com.ss.android.article.base.app.k;
import com.ss.android.article.base.app.t;
import com.ss.android.article.base.feature.detail2.DetailIntentCreator;
import com.ss.android.article.browser.download.DownloadTaskManager;
import com.ss.android.common.applog.NetUtil;
import com.ss.android.common.util.ToolUtils;
import com.ss.android.messagebus.SubscriptionRouter;
import com.ss.android.newmedia.MediaAppDataProvider;

import im.quar.autolayout.config.AutoLayoutConfig;

public class ArticleApplication extends BizApplication {
    static {
        com.ss.android.l.c.b();
    }

    public ArticleApplication() {
        super("news_browser", "1212", "news-browser-android", 1212);
        com.bytedance.ttstat.a.c(this);
        com.bytedance.ttstat.a.c();
    }

    protected void attachBaseContext(Context context) {
        super.attachBaseContext(context);
        ToolUtils.isMainProcess(this);
        ArticleApplication.b = true;
        com.bytedance.ttstat.a.c(this);
        com.ss.android.l.c.c();
    }

    public final void m() {
        com.ss.android.l.c.c();
        e.a();
        com.ss.android.l.c.c();
        super.m();
        com.ss.android.l.c.c();
        com.ss.android.account.v2.aa v0 = com.ss.android.account.v2.aa.getInstance();
        v0.a(new com.ss.android.article.base.app.account.a(this));
        ComponentsManifest.addComponent(com.ss.android.account.v2.bb.class, v0);
        com.ss.android.l.c.c();
        ComponentsManifest.addComponent(com.ss.android.newmedia.c.a.class, new t());
        com.ss.android.l.c.c();
        ComponentsManifest.addComponent(DetailIntentCreator.class, com.ss.android.article.common.e.a.a().b());
        com.ss.android.l.c.c();
        com.ss.android.l.c.c();
        com.bytedance.frameworks.b.a.c.a(com.ss.android.dd.class, new k());
        com.ss.android.l.c.c();
        com.ss.android.l.c.c();
        try {
            AutoLayoutConfig.init(this);
        } catch (Exception v0_1) {
        }

        com.ss.android.l.c.c();
        com.ss.android.article.base.utils.a.b.migrateSp();
        com.ss.android.l.c.c();
        try {
            com.ss.android.newmedia.message.c.a();
            this.getApplicationContext();
            com.ss.android.newmedia.message.c.i();
        } catch (Exception exception) {
            Logger.e("ArticleApplication", "Failed to handleAllowSettingsNotifyEnable", exception);
        }

        com.ss.android.l.c.c();
        this.y();
        com.ss.android.l.c.c();
        PullToRefreshBase.setAnimationStyle(new j());
        com.ss.android.l.c.c();
    }

    public final void n() {
        super.n();
        this.A();
    }

    public final void o() {
        super.o();
        com.ss.android.article.browser.lockscreen.c.a();
    }

    public void onCreate() {
        long v4 = 0;
        com.ss.android.l.c.c();
        if (ToolUtils.isMainProcess(((Context) this))) {
            com.bytedance.article.common.launchcrash.f.a(((Context) this), new com.bytedance.article.common.launchcrash.a.a$a());
        }

        com.bytedance.ttstat.a.a(this);
        ComponentsManifest.addComponent(MediaAppDataProvider.class, new com.ss.android.article.lite.a.a());
        super.onCreate();
        if (!ToolUtils.isMainProcess(((Context) this))) {
            e.a();
            com.ss.android.l.c.c();
            return;
        }

        try {
            Class.forName("com.ss.android.article.base.utils.messageBus.customConfig.RegisterCustomTaskStatic");
        } catch (Exception v0) {
        }

        com.bytedance.ttstat.a.a(this, new com.bytedance.ttstat.a.a$a(this));
        com.bytedance.ttstat.a.d(this);
        com.ss.android.article.common.b.b.a().a(((Context) this), new com.ss.android.article.common.d.a());
        AutoLayoutConfig.init(((Context) this), new com.ss.android.article.lite.c(this));
        ((UiModeManager) getSystemService(Context.UI_MODE_SERVICE)).setNightMode(UiModeManager.MODE_NIGHT_NO);
        if (ArticleApplication.b) {
            if (this.d != null) {
                try {
                    this.d.await();
                } catch (InterruptedException v0_1) {
                    v0_1.printStackTrace();
                }
            }

            com.ss.android.l.c.c();
            com.ss.android.article.lite.aa v0_2 = new com.ss.android.article.lite.aa(new com.ss.android.article.lite.d(this));
            SubscriptionRouter.addSubscriber(v0_2);
            v0_2.a.sendEmptyMessageDelayed(0, 10000);
            com.ss.android.l.c.c();
            if (!ArticleApplication.b) {
//                goto label_68;
            } else if (this.D() == null) {
//                goto label_68;
            } else {
                long v0_3 = this.D().getLong("tt_launch_delay_time", v4);
                if (v0_3 <= v4) {
//                goto label_68;
                } else {
                    try {
                        Logger.i("ArticleApplication", "Delay launch.");
                        Thread.sleep(v0_3);
                    } catch (Throwable v0_4) {
                        Logger.e("ArticleApplication", "Failed to sleep main thread.", v0_4);
                    }
                }
            }
        }
        DownloadTaskManager.getInstance();
        com.ss.android.article.browser.lockscreen.e.b().a(((Context) this));
        NetUtil.a(new NetUtil.b());
        com.ss.android.article.base.utils.e.b(10001);
        com.bytedance.ttstat.a.e(this);
        com.ss.android.l.c.c();
    }
}

